import { ICommonParams } from '../../interfaces';
import get_sessionid from '../authorization-b/_get-sessionid';
import send_msg from './_service';

const IS_ONLINE = 'loginservice.isonline4js.intranet';

export default async function user_isonline(_action_id: string, _session_id: string, _spaceid: string, _msg: ICommonParams) {
	const sessionid = get_sessionid();
	if (sessionid) {
		const param = {
			sessionid
		};
		const data = await send_msg<{ code: 'false' | string; }>(IS_ONLINE, param, false, false);
		const code = data.code;
		if (code === 'false') {
			return false;
		}
		return true;
	}
	return false;
}
